package com.whynot.frame.spring.mybatis.client;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.whynot.frame.spring.mybatis.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;


import com.whynot.frame.spring.mybatis.entities.User;
import com.whynot.frame.spring.mybatis.mapper.CourseMapper;
import com.whynot.frame.spring.mybatis.mapper.UserMapper;
import com.whynot.frame.spring.mybatis.util.SqlSessionFactoryUtil;

public class Main {
	
	public static void main(String[] args) {
		SqlSession sqlSession = SqlSessionFactoryUtil.openSession();
		UserMapper userDao = sqlSession.getMapper(UserMapper.class);
		CourseMapper courseDao = sqlSession.getMapper(CourseMapper.class);
		//add
		/*User user= new User("curtain", "123");
		int i = userDao.addUser(user);
		sqlSession.commit();
		if(i>0){
			System.out.println("添加成功");
		}*/
		//System.out.println(userDao.getAll());
		
	/*	List<User> lists = sqlSession.selectList("com.whynot.frame.spring.mybatis.dao.UserMapper.queryById", 1);
		System.out.println(lists);*/
		
		//System.out.println(userDao.findUserWhithAddress(1));
		
		/*System.out.println(courseDao.findCourseById(1));*/
		Map<String,Object> map = new HashMap<String,Object>(); 
		map.put("courseId", 1);
		map.put("username", "curtain");
		map.put("pwd", "123");
		System.out.println(userDao.searchUserByMap(map));
		
	}
}
